.class public final Lcom/baidu/crabsdk/sender/b;
.super Ljava/lang/Thread;


# static fields
.field private static bu:Z


# instance fields
.field private final aj:Landroid/content/Context;

.field private final bA:Ljava/lang/Runnable;

.field private final bv:Ljava/lang/ref/SoftReference;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/lang/ref/SoftReference<",
            "Landroid/os/Looper;",
            ">;"
        }
    .end annotation
.end field

.field private bw:Ljava/lang/ref/SoftReference;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/lang/ref/SoftReference<",
            "Landroid/os/Handler;",
            ">;"
        }
    .end annotation
.end field

.field private final bx:I

.field private volatile by:I

.field private bz:Lcom/baidu/crabsdk/sender/a;


# direct methods
.method static constructor <clinit>()V
    .locals 0

    return-void
.end method

.method public constructor <init>(Landroid/content/Context;)V
    .locals 2

    invoke-direct {p0}, Ljava/lang/Thread;-><init>()V

    new-instance v0, Ljava/lang/ref/SoftReference;

    invoke-static {}, Landroid/os/Looper;->getMainLooper()Landroid/os/Looper;

    move-result-object v1

    invoke-direct {v0, v1}, Ljava/lang/ref/SoftReference;-><init>(Ljava/lang/Object;)V

    iput-object v0, p0, Lcom/baidu/crabsdk/sender/b;->bv:Ljava/lang/ref/SoftReference;

    const/4 v0, 0x0

    iput v0, p0, Lcom/baidu/crabsdk/sender/b;->by:I

    new-instance v0, Lcom/baidu/crabsdk/sender/c;

    invoke-direct {v0, p0}, Lcom/baidu/crabsdk/sender/c;-><init>(Lcom/baidu/crabsdk/sender/b;)V

    iput-object v0, p0, Lcom/baidu/crabsdk/sender/b;->bA:Ljava/lang/Runnable;

    iput-object p1, p0, Lcom/baidu/crabsdk/sender/b;->aj:Landroid/content/Context;

    const/16 v0, 0xbb8

    iput v0, p0, Lcom/baidu/crabsdk/sender/b;->bx:I

    new-instance v0, Lcom/baidu/crabsdk/sender/a;

    invoke-direct {v0, p1}, Lcom/baidu/crabsdk/sender/a;-><init>(Landroid/content/Context;)V

    iput-object v0, p0, Lcom/baidu/crabsdk/sender/b;->bz:Lcom/baidu/crabsdk/sender/a;

    return-void
.end method

.method static synthetic a(Lcom/baidu/crabsdk/sender/b;)I
    .locals 0

    iget p0, p0, Lcom/baidu/crabsdk/sender/b;->by:I

    return p0
.end method

.method static synthetic a(Lcom/baidu/crabsdk/sender/b;I)I
    .locals 0

    iput p1, p0, Lcom/baidu/crabsdk/sender/b;->by:I

    return p1
.end method


# virtual methods
.method public final run()V
    .locals 5

    new-instance v0, Ljava/lang/StringBuilder;

    const-string v1, "***isRunning = "

    invoke-direct {v0, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    sget-boolean v1, Lcom/baidu/crabsdk/sender/b;->bu:Z

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Z)Ljava/lang/StringBuilder;

    const-string v1, "***"

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-static {v0}, Lcom/baidu/crabsdk/c/a;->u(Ljava/lang/String;)I

    sget-boolean v0, Lcom/baidu/crabsdk/sender/b;->bu:Z

    if-eqz v0, :cond_0

    return-void

    :cond_0
    const/4 v0, 0x1

    sput-boolean v0, Lcom/baidu/crabsdk/sender/b;->bu:Z

    const-string v0, "|AnrWatchThread|"

    invoke-virtual {p0, v0}, Ljava/lang/Thread;->setName(Ljava/lang/String;)V

    const-string v0, "AnrWatchThread start!"

    invoke-static {v0}, Lcom/baidu/crabsdk/c/a;->s(Ljava/lang/String;)I

    :cond_1
    invoke-virtual {p0}, Ljava/lang/Thread;->isInterrupted()Z

    move-result v0

    const/4 v1, 0x0

    if-nez v0, :cond_7

    iget v0, p0, Lcom/baidu/crabsdk/sender/b;->by:I

    iget-object v2, p0, Lcom/baidu/crabsdk/sender/b;->bv:Ljava/lang/ref/SoftReference;

    invoke-virtual {v2}, Ljava/lang/ref/SoftReference;->get()Ljava/lang/Object;

    move-result-object v2

    if-nez v2, :cond_3

    :cond_2
    :goto_0
    sput-boolean v1, Lcom/baidu/crabsdk/sender/b;->bu:Z

    goto :goto_1

    :cond_3
    :try_start_0
    iget-object v2, p0, Lcom/baidu/crabsdk/sender/b;->bw:Ljava/lang/ref/SoftReference;

    if-eqz v2, :cond_4

    iget-object v2, p0, Lcom/baidu/crabsdk/sender/b;->bw:Ljava/lang/ref/SoftReference;

    invoke-virtual {v2}, Ljava/lang/ref/SoftReference;->get()Ljava/lang/Object;

    move-result-object v2

    if-nez v2, :cond_5

    :cond_4
    new-instance v2, Ljava/lang/ref/SoftReference;

    new-instance v3, Landroid/os/Handler;

    iget-object v4, p0, Lcom/baidu/crabsdk/sender/b;->bv:Ljava/lang/ref/SoftReference;

    invoke-virtual {v4}, Ljava/lang/ref/SoftReference;->get()Ljava/lang/Object;

    move-result-object v4

    check-cast v4, Landroid/os/Looper;

    invoke-direct {v3, v4}, Landroid/os/Handler;-><init>(Landroid/os/Looper;)V

    invoke-direct {v2, v3}, Ljava/lang/ref/SoftReference;-><init>(Ljava/lang/Object;)V

    iput-object v2, p0, Lcom/baidu/crabsdk/sender/b;->bw:Ljava/lang/ref/SoftReference;

    :cond_5
    iget-object v2, p0, Lcom/baidu/crabsdk/sender/b;->bw:Ljava/lang/ref/SoftReference;

    invoke-virtual {v2}, Ljava/lang/ref/SoftReference;->get()Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Landroid/os/Handler;

    iget-object v3, p0, Lcom/baidu/crabsdk/sender/b;->bA:Ljava/lang/Runnable;

    invoke-virtual {v2, v3}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z

    iget v2, p0, Lcom/baidu/crabsdk/sender/b;->bx:I

    int-to-long v2, v2

    invoke-static {v2, v3}, Ljava/lang/Thread;->sleep(J)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    sget-boolean v2, Lcom/baidu/crabsdk/a;->I:Z

    if-nez v2, :cond_6

    sput-boolean v1, Lcom/baidu/crabsdk/sender/b;->bu:Z

    const-string v0, "anr watch thread is breakdown!"

    invoke-static {v0}, Lcom/baidu/crabsdk/c/a;->w(Ljava/lang/String;)I

    goto :goto_1

    :cond_6
    iget v2, p0, Lcom/baidu/crabsdk/sender/b;->by:I

    if-ne v2, v0, :cond_1

    iget-object v0, p0, Lcom/baidu/crabsdk/sender/b;->aj:Landroid/content/Context;

    if-eqz v0, :cond_2

    sget-boolean v0, Lcom/baidu/crabsdk/a;->J:Z

    if-nez v0, :cond_2

    const-string v0, "onAppNotResponding!"

    invoke-static {v0}, Lcom/baidu/crabsdk/c/a;->s(Ljava/lang/String;)I

    iget-object v0, p0, Lcom/baidu/crabsdk/sender/b;->bz:Lcom/baidu/crabsdk/sender/a;

    const-string v2, "/data/anr/traces.txt"

    invoke-virtual {v0, v2}, Lcom/baidu/crabsdk/sender/a;->d(Ljava/lang/String;)V

    goto :goto_0

    :catch_0
    move-exception v0

    new-instance v2, Ljava/lang/StringBuilder;

    const-string v3, "AnrWatchThread Exception: "

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v0}, Ljava/lang/Exception;->getMessage()Ljava/lang/String;

    move-result-object v0

    invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-static {v0}, Lcom/baidu/crabsdk/c/a;->v(Ljava/lang/String;)I

    goto :goto_0

    :cond_7
    :goto_1
    sput-boolean v1, Lcom/baidu/crabsdk/sender/b;->bu:Z

    const-string v0, "anr watch thread is over!"

    invoke-static {v0}, Lcom/baidu/crabsdk/c/a;->w(Ljava/lang/String;)I

    return-void
.end method
